<?php 

	$username = $_POST['username'];

	$preg = '/^[a-z][0-9a-z]{5,7}$/';

	$c = preg_match($preg, $username);

	if (!$c) {
		$arr = array(
			'error'=>1,
			'info'=>'请使用以字母开头，长度6-8位作为用户名',
			);

		echo json_encode($arr);
		exit();
	};

	$users = include "./users.php";
	foreach ($users as $v) {
			if ($v['username']==$username) {
				$arr = array(
				'error'=>1,
				'info'=>'用户名已存在',
				);

			echo json_encode($arr);
			exit();
			}
	}

	$arr = array(
		'error'=>0,
		'info'=>'用户名可用',
		);

	echo json_encode($arr);

 ?>